package cn.chenli.job.model;

import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import org.asyou.mongo.annotation.Collection;

import java.io.Serializable;
import java.util.Date;

/**
 * 定时器
 *
 * @author chenli
 * @create 2017-08-11
 */
@Collection(name = "quartz_job")
public class QuartzJob implements Serializable {
    /**
     * 任务调度参数key
     */
//    public static final String JOB_PARAM_KEY = "JOB_PARAM_KEY";
    /**
     * 自定义主键
     */
    private String id;

    /**
     * 任务名称
     */
    private String name;

    /**
     * cron表达式
     */
    private String cron;

    //执行脚本
    private String script;

    /**
     * 脚本语言
     */
    private String  language;

    /**
     * 是否启用
     */
    private Boolean enabled;

    /**
     * 启动参数
     */
    private String  parameters;
    /**
     * 任务类型
     */
    private Integer  type;
    /**
     * 任务状态  0：正常  1：暂停
     */
    private Integer status;

    /**
     * 备注
     */
    private String remark;

    /**
     * 创建时间
     */
    private Date addTime;

    public String getId() {
        return id;
    }

    public QuartzJob setId(String id) {
        this.id = id;
        return this;
    }

    public String getName() {
        return name;
    }

    public QuartzJob setName(String name) {
        this.name = name;
        return this;
    }

    public String getCron() {
        return cron;
    }

    public QuartzJob setCron(String cron) {
        this.cron = cron;
        return this;
    }

    public String getScript() {
        return script;
    }

    public QuartzJob setScript(String script) {
        this.script = script;
        return this;
    }

    public String getLanguage() {
        return language;
    }

    public QuartzJob setLanguage(String language) {
        this.language = language;
        return this;
    }

    public Boolean isEnabled() {
        return enabled;
    }

    public QuartzJob setEnabled(Boolean enabled) {
        this.enabled = enabled;
        return this;
    }

    public String getParameters() {
        return parameters;
    }

    public QuartzJob setParameters(String parameters) {
        this.parameters = parameters;
        return this;
    }

    public Integer getType() {
        return type;
    }

    public QuartzJob setType(Integer type) {
        this.type = type;
        return this;
    }

    public Integer getStatus() {
        return status;
    }

    public QuartzJob setStatus(Integer status) {
        this.status = status;
        return this;
    }

    public String getRemark() {
        return remark;
    }

    public QuartzJob setRemark(String remark) {
        this.remark = remark;
        return this;
    }

    public Date getAddTime() {
        return addTime;
    }

    public QuartzJob setAddTime(Date addTime) {
        this.addTime = addTime;
        return this;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        QuartzJob quartzJob = (QuartzJob) o;
        return enabled == quartzJob.enabled &&
                type == quartzJob.type &&
                Objects.equal(id, quartzJob.id) &&
                Objects.equal(name, quartzJob.name) &&
                Objects.equal(cron, quartzJob.cron) &&
                Objects.equal(script, quartzJob.script) &&
                Objects.equal(language, quartzJob.language) &&
                Objects.equal(parameters, quartzJob.parameters) &&
                Objects.equal(status, quartzJob.status) &&
                Objects.equal(remark, quartzJob.remark) &&
                Objects.equal(addTime, quartzJob.addTime);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(id, name, cron, script, language, enabled, parameters, type, status, remark, addTime);
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                .add("id", id)
                .add("name", name)
                .add("cron", cron)
                .add("script", script)
                .add("language", language)
                .add("enabled", enabled)
                .add("parameters", parameters)
                .add("type", type)
                .add("status", status)
                .add("remark", remark)
                .add("addTime", addTime)
                .toString();
    }
}
